package com.mit.facade;

import org.apache.log4j.Logger;

import com.mit.common.RequestContext;
import com.mit.common.ResultContext;
import com.mit.common.security.dto.UserDTO;
import com.mit.common.token.SecurityTokens;
import com.mit.service.security.dao.IUserDAO;

public class SecurityFacade implements ISecurityFacade {

	private Logger logger = Logger.getLogger(SecurityFacade.class);
	private IUserDAO userDAO;
	
	public IUserDAO getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(IUserDAO userDAO) {
		this.userDAO = userDAO;
	}

	@Override
	public ResultContext retrieveUserByNamePwd(RequestContext rqs) {
		String username = (String) rqs.getParameter(SecurityTokens.KEY_USERNAME);
		String password = (String) rqs.getParameter(SecurityTokens.KEY_PASSWORD);
		UserDTO user = userDAO.retrieveUser(username, password);
		ResultContext rlt = new ResultContext();
		rlt.addResult(SecurityTokens.KEY_USER_DTO, user);
		return rlt;
	}

}
